package models;

import play.*;
import play.db.jpa.*;

import javax.persistence.*;
import java.util.*;

/**
 * This is the comment class which has the attributed body, tutId, commenterId,
 * isPrivate, commentDate.There's a toString method that i use it further on in
 * displaying the comments
 * 
 * 
 * @author Rana A. Zakaria
 */
@Entity
public class Comment extends Model {
	public String body;
	public long tutId;
	public long commentorId;
	public boolean isPrivate;
	public Date commentDate = new Date();

	public Comment(String comment, long tutId, long commentorId,
			boolean isPrivate) {
		body = comment;
		this.commentorId = commentorId;
		this.tutId = tutId;
		this.isPrivate = isPrivate;
	}

	/**
	 * This method returns a string of the comment and who posted it
	 * 
	 * 
	 * @author Rana A. Zakaria
	 */
	public String toString() {
		RegisteredUser user = RegisteredUser.findById(this.commentorId);
		String s = user.name + " posted:  " + this.body; // +
															// "                    at ";
															// +
															// this.commentDate;
		return s;
	}
}